package com.xishu.service;

public class StringService {
    private static StringService instance = new StringService();

    private StringService() {
    }

    public static StringService getInstance() {
        return instance;
    }

    /**
     * 产生多少个空格的字符串
     *
     * @param size
     * @return
     */
    public String generateSpace(int size) {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < size; i++) {
            stringBuilder.append(" ");
        }

        return stringBuilder.toString();
    }

    /**
     * 获取字符串
     *
     * @param str
     * @param defaultStr
     * @return
     */
    public String getString(String str, String defaultStr) {
        if (str == null) {
            return defaultStr;
        }

        return str;
    }

}
